package org.cloudnote.util;

import java.util.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

//import java.util.Base64;
//
//// 编码示例
//String encoded = Base64.getEncoder().encodeToString(original.getBytes());
//// 解码示例
//        byte[] decoded = Base64.getDecoder().decode(encoded);

public class NoteUtil {

    public static String createdId(){
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }

    public static String md5(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] input = str.getBytes();
            byte[] output = md.digest(input);
            return Base64.getEncoder().encodeToString(output);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return "";
        }
    }

    public static void main(String[] args) {
        //String s = createdId();
        // System.out.println("s = " + s);
        String s = md5("123");
        System.out.println("s = " + s); //ICy5YqxZB1uWSwcVLSNLcA==
    }

}